//
//  SimplePhotoBrowser.swift
//  Swift-30-demo
//
//  Created by apple on 2021/12/2.
//

import UIKit

class SimplePhotoBrowser: UIViewController, UIScrollViewDelegate {
    let imageView: UIImageView = UIImageView()
    let scrollView: UIScrollView = UIScrollView()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.title = "SimplePhotoBrowser"
        self.view.backgroundColor = UIColor.white
        // Do any additional setup after loading the view.
        
        scrollView.frame = CGRect(x: self.view.frame.origin.x, y: self.view.frame.origin.y + navgationHeight, width: self.view.frame.size.width, height: self.view.frame.size.height - navgationHeight)
        scrollView.maximumZoomScale = 4.0
        scrollView.minimumZoomScale = 1
        scrollView.backgroundColor = UIColor.black
        scrollView.delegate = self
        self.view.addSubview(scrollView)
        
        imageView.frame = self.view.bounds
        imageView.image = UIImage(named: "samplePhoto.jpeg")
        imageView.isUserInteractionEnabled = true
        imageView.contentMode = UIView.ContentMode.scaleAspectFit
        scrollView.addSubview(imageView)
        
        scrollView.contentSize = imageView.bounds.size
    }
    
    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return imageView
    }
    
}
